package com.zxl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zxl.entity.Address;
import com.zxl.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @packageName com.zxl.controller
 * @ClassName
 * @Author zxl
 * @Description //TODO
 * @date
 **/
@RestController
@RequestMapping("/address")
public class AddressConttroller {

    @Autowired
    private AddressService addressService;

    @RequestMapping("/list")
    public List<Address> listByUid(@RequestParam("uid")Integer uid){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("uid",uid);
        return addressService.list(wrapper);
    }

    @RequestMapping("/add")
    public void add(@RequestBody Address address){
        addressService.insert(address);
    }

    @RequestMapping("/getById")
    Address getById(@RequestParam("id") Integer aid){
        return addressService.getById(aid);
    }

}
